package com.ajnp.springcloud.controller;

import com.ajnp.springcloud.service.PaymentFeignService;
import entities.CommonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/consumer")
@Slf4j
@RestController
public class OrderFeignController {

    @Autowired
    private PaymentFeignService paymentFeignService;

    //客户端的访问地址
    @GetMapping("/payment/getpaymentById/{id}")
    public CommonResult getPaymentById(@PathVariable("id") Long id) {
        return paymentFeignService.feign_getPaymentById(id);
    }

    @GetMapping("/payment/paymentsleep")
    public String feign_paymentFeignTimeout() {
        //openfeign-ribbon 客户端一般默认等待1秒钟 而我编写一个故意停止3秒的方法
        //openfeign默认等待1秒 超时报错  Read timed out executing GET http://CLOUD-PAYMENT-SERVICE/payment/paymentsleep
        //通过修改yml文件 中的ribbon属性 将时间延长到5秒
        return paymentFeignService.feign_paymentFeignTimeout();
    }


}
